package io.renren.modules.app.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import io.renren.modules.app.entity.ImFriendEntity;
import io.renren.modules.app.entity.UserEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 *
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2020-04-26 13:24:53
 */
@Mapper
public interface ImFriendDao extends BaseMapper<ImFriendEntity> {

    @Select("SELECT f.id,f.friend_id user_id,IF(f.nickname='',u.nickname,f.nickname) name,u.username,u.avatar FROM im_friend f,tb_user u WHERE f.friend_id=u.user_id and f.user_id=#{user.userId}")
    List<ImFriendEntity> getListById(@Param("user") UserEntity user);
}
